package com.tianyalei.wolf.sample.activity.activityanim;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.view.View;
import android.widget.ImageView;

import com.tianyalei.wolf.sample.R;
import com.tianyalei.wolf.sample.activity.base.BaseToolBarActivity;
import com.tianyalei.wolf.sample.imageload.ImageLoadProxy;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class AnimActivity extends BaseToolBarActivity {

    @Bind(R.id.scale_anim)
    ImageView scaleAnimImage;

    String demoUri = "http://pic.pp3.cn/uploads//allimg/111110/15563RI9-7.jpg";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ButterKnife.bind(this);

        ImageLoadProxy.displayCircleImage(this, demoUri, scaleAnimImage);
    }

    @Override
    protected int getLayoutResource() {
        return R.layout.activity_anim;
    }

    @OnClick(R.id.scale_anim)
    public void onClick() {
        launch(scaleAnimImage);
    }

    private void launch(View view) {
//        ActivityOptionsCompat compat = ActivityOptionsCompat.makeScaleUpAnimation(view,
//                view.getWidth() / 2, view.getHeight() / 2, 0, 0);
//        view.setDrawingCacheEnabled(true);
//        ActivityOptionsCompat compat = ActivityOptionsCompat.makeThumbnailScaleUpAnimation(view, view.getDrawingCache(), 0, 0);
//        ActivityCompat.startActivity(this, new Intent(this, MainActivity.class),
//                compat.toBundle());
        ActivityOptionsCompat compat = ActivityOptionsCompat.makeSceneTransitionAnimation(this, scaleAnimImage, "imagename");

        Intent intent = new Intent(this, DetailActivity.class);
        intent.putExtra("imagename", demoUri);
        ActivityCompat.startActivity(this, intent, compat.toBundle());

    }
}
